package com.baosight.risk.service.jlta.impl;

import com.baosight.risk.api.jlta.JltaResourceService;
import com.baosight.risk.common.utils.ShiroUtils;
import com.baosight.risk.mapper.jlta.JltaResourceMapper;
import com.baosight.risk.service.jlta.entity.JltaResource;
import com.baosight.risk.service.jlta.vo.JltaResourceVO;
import com.baosight.risk.service.xtzy.entity.XtzyUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作者： lishaoqing
 * 时间： 2019年07月10日
 * 描述： JltaResourceServiceImpl
 * 版本: v1.0
 */
@Service
public class JltaResourceServiceImpl implements JltaResourceService {

    @Autowired
    private JltaResourceMapper jltaResourceMapper;

    @Override
    public List<JltaResource> selectSelfResourceList(JltaResource jltaResource) {
        XtzyUser user = ShiroUtils.getUser();
        jltaResource.setCreateBy(user.getUserCode());
        return jltaResourceMapper.selectSelfResourceList(jltaResource);
    }

    @Override
    public List<JltaResource> selectSharedResourceList(String userId) {
        return jltaResourceMapper.selectSharedResourceList(userId);
    }

    @Override
    public List<JltaResourceVO> selectFileList(String resourceCode) {
        return jltaResourceMapper.selectFileList(resourceCode);
    }

    @Override
    public Integer addResource(JltaResource jltaResource) {
        return jltaResourceMapper.insert(jltaResource);
    }

    @Override
    public Integer editResource(JltaResource jltaResource) {
        return jltaResourceMapper.editResource(jltaResource);
    }

    @Override
    public Integer deleteResource(JltaResource jltaResource) {
        return jltaResourceMapper.deleteResource(jltaResource);
    }

    @Override
    public List<JltaResource> getResourceByTeam(String teamId) {
        return jltaResourceMapper.getResourceByTeam(teamId);
    }
}
